package com.learn.step08freemarker.viewHandle.sitemesh;


import org.sitemesh.SiteMeshContext;
import org.sitemesh.content.ContentProperty;
import org.sitemesh.content.tagrules.TagRuleBundle;
import org.sitemesh.content.tagrules.html.ExportTagToContentRule;
import org.sitemesh.tagprocessor.State;

/**
 * 自定义标签
 * Created by Webster on 16/4/23.
 */
public class MyTagRuleBundle implements TagRuleBundle {

    @Override
    public void install(State defaultState, ContentProperty contentProperty,
                        SiteMeshContext siteMeshContext) {
        /*标签名必须全部小写*/
        defaultState.addRule("css_plugins", new ExportTagToContentRule(siteMeshContext,contentProperty.getChild("css_plugins"), false));
        defaultState.addRule("css_page", new ExportTagToContentRule(siteMeshContext,contentProperty.getChild("css_page"), false));
        defaultState.addRule("css_theme", new ExportTagToContentRule(siteMeshContext,contentProperty.getChild("css_theme"), false));
        defaultState.addRule("js_plugins", new ExportTagToContentRule(siteMeshContext,contentProperty.getChild("js_plugins"), false));
        defaultState.addRule("js_page", new ExportTagToContentRule(siteMeshContext,contentProperty.getChild("js_page"), false));
        defaultState.addRule("js_theme", new ExportTagToContentRule(siteMeshContext,contentProperty.getChild("js_theme"), false));
        defaultState.addRule("bath_path", new ExportTagToContentRule(siteMeshContext,contentProperty.getChild("bath_path"), false));

    }

    @Override
    public void cleanUp(State defaultState, ContentProperty contentProperty,
                        SiteMeshContext siteMeshContext) {

    }

}